#include "AllocateDataGame.h"
#include "FiniteStateMachine.h"
#include "StartCompetitions.h"


AllocateDataGame::AllocateDataGame(void)
{
}


AllocateDataGame::~AllocateDataGame(void)
{
}

void AllocateDataGame::Execute(void *aFsm)
{
	FiniteStateMachine<Game>* fsm= reinterpret_cast<FiniteStateMachine<Game>*>(aFsm);
	Game *game= fsm->mActor;
	game->boxerArray=new Boxer*[game->mNumChallengers];
	game->challengeTree=new Tree<Boxer>;
	game->challengeTree->CreateTree(game->mNumChallengers);
	PlayerFactory pf;
	Boxer *player= pf.CreateBoxer();
	player->SetName(pf.SetName());
	pf.SetSkills(player,4);
	pf.SetHitPoints(player,10);
	pf.ViewStats(player);
	game->boxerArray[0]=player;
	game->challengeTree->InsertOnLeaf(player);
	BoxerFactory bf;	
	for(size_t i=1; i < game->mNumChallengers; i++)
	{		
		Boxer *b= bf.CreateBoxer();
		game->boxerArray[i]=b;
		b->SetName(bf.SetName());
		bf.SetSkills(b,4);
		bf.SetHitPoints(b,10);
		bf.ViewStats(game->boxerArray[i]);
		game->challengeTree->InsertOnLeaf(b);
	}
	fsm->ChangeState(new StartCompetitions());
}

